package com.css.fxfzypg.modules.rating.task.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.css.fxfzypg.base.dict.service.DictItemService;
import com.css.fxfzypg.base.dict.service.DictService;
import com.css.fxfzypg.constants.BuildingStructureConstants;
import com.css.fxfzypg.manage.building.repository.BuildingReqository;
import com.css.fxfzypg.manage.lethalitydifference.repository.LethalityDifferenceRepository;
import com.css.fxfzypg.manage.sampling.repository.SamplingReqository;
import com.css.fxfzypg.manage.sampling.repository.entity.SamplingEntity;
import com.css.fxfzypg.modules.baseData.repository.*;
import com.css.fxfzypg.modules.baseData.service.*;
import com.css.fxfzypg.modules.dataVolumeStatistics.repository.DataLumeRepository;
import com.css.fxfzypg.modules.dataVolumeStatistics.vo.HeightAndSlopeVO;
import com.css.fxfzypg.modules.maps.service.AreaMapService;
import com.css.fxfzypg.modules.maps.service.PbeMapService;
import com.css.fxfzypg.modules.model.repository.*;
import com.css.fxfzypg.modules.preassesstaskmanage.entity.PreAssessTaskEntity;
import com.css.fxfzypg.modules.preassesstaskmanage.service.PreAssessTaskService;
import com.css.fxfzypg.modules.rating.library.constants.KpPtgxCode;
import com.css.fxfzypg.modules.rating.library.dao.KpExamIndex3PeekDataDao;
import com.css.fxfzypg.modules.rating.library.model.entity.KpExamIndex3PeekData;
import com.css.fxfzypg.modules.resultManagement.reportManagement.entity.FieldReportManagement;
import com.css.fxfzypg.modules.resultManagement.reportManagement.entity.ReportManagement;
import com.css.fxfzypg.modules.resultManagement.reportManagement.repository.ReportManagementRepository;
import com.css.fxfzypg.modules.resultManagement.reportManagement.repository.SamplingSurveyReportRepository;
import com.css.fxfzypg.modules.resultsManagement.entity.MapType;
import com.css.fxfzypg.modules.resultsManagement.repository.MapManagementRepository;
import com.css.fxfzypg.modules.resultsManagement.repository.MapTypeRepository;
import com.css.fxfzypg.modules.statistics.repository.StatisticsRepository;
import com.css.fxfzypg.modules.statistics.service.StatisticsService;
import com.css.fxfzypg.modules.suggestinfo.manage.annualriskManage.repository.AnnualRiskManageRepository;
import com.css.fxfzypg.modules.suggestinfo.manage.disasterscenarioManage.repository.DisasterScenarioManageRepository;
import com.css.fxfzypg.modules.suggestinfo.manage.emergencydisasterManage.repository.EmergencyDisasterManageRepository;
import com.css.fxfzypg.modules.suggestinfo.manage.emergencydisposalManage.repository.EmergencyDisposalManageRepository;
import com.css.fxfzypg.modules.surveytaskmanage.entity.FieldSurveyTaskEntity;
import com.css.fxfzypg.modules.surveytaskmanage.service.FieldSurveyTaskService;
import com.css.fxfzypg.util.PlatformObjectUtils;
import com.css.fxfzypg.zcpt.sys.service.SysAreaService;
import com.css.fxfzypg.zcpt.sys.service.impl.SysAreaCacheService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class RunSystemScoreService {
    @Resource
    private EarthquakeDisasterRepository earthquakeDisasterRepository;
    @Resource
    private HisPrRepository hisPrRepository;
    @Resource
    CountiesConditionRepository countiesConditionRepository;
    @Resource
    private HosPeoRepository hosPeoRepository;
    @Resource
    private PeoService peoService;
    @Resource
    BuildingVulnerabilityService buildingVulnerabilityService;
    @Resource
    private HouseService houseService;
    @Resource
    private KeyProjectService keyProjectService;
    @Resource
    private GdpService gdpService;
    @Resource
    SeismicSetoutService seismicSetoutService;
    @Resource
    AreaMapService areaMapService;//地图使用
    @Resource
    ElevationService elevationService;
    @Autowired
    StatisticsService statisticsService;
    @Resource
    public PbeRepository pbeRepository;
    @Resource
    public RoadRepository roadRepository;
    @Resource
    public AirportRepository airportRepository;
    @Resource
    public ReservoirRepository reservoirRepository;
    @Resource
    public SchoolRepository schoolRepository;
    @Resource
    public HospitalRepository hospitalRepository;
    @Resource
    public GeologicalRepository geologicalRepository;
    @Resource
    public FaultageRepository faultageRepository;
    @Autowired
    RiskEnterpriseDataRepository riskEnterpriseDataRepository;
    @Autowired
    GasstationDataRepository gasstationDataRepository;
    @Autowired
    EmergencyShelterRepository emergencyShelterRepository;
    @Resource
    private IntensityAttenuationRepository intensityAttenuationRepository;
    @Resource
    private CasualtyRepository casualtyRepository;
    @Resource
    private EconomicLossesRepository economicLossesRepository;
    @Resource
    ResettlementPersonnelRepository resettlementPersonnelRepository;
    @Autowired
    private RescueForceRepository rescueForceRepository;
    @Resource
    private MaterialRepository materialRepository;
    @Autowired
    LethalityDifferenceRepository lethalityDifferenceRepository;
    @Autowired
    SamplingReqository samplingReqository;
    @Autowired
    BuildingReqository buildingReqository;
    @Autowired
    DisasterScenarioManageRepository disasterScenarioManageRepository;
    @Autowired
    AnnualRiskManageRepository annualRiskManageRepository;
    @Autowired
    EmergencyDisasterManageRepository emergencyDisasterManageRepository;
    @Autowired
    EmergencyDisposalManageRepository emergencyDisposalManageRepository;
    @Autowired
    PreAssessTaskService preAssessTaskService;
    @Autowired
    private SysAreaCacheService sysAreaCacheService;
    @Autowired
    HistoricalSeismicDataRepository historicalSeismicDataRepository;
    @Autowired
    private SysAreaService sysAreaService;
    @Autowired
    FieldSurveyTaskService fieldSurveyTaskService;
    @Resource
    private ReportManagementRepository reportManagementRepository;
    @Resource
    private SamplingSurveyReportRepository samplingSurveyReportRepository;
    @Resource
    MapTypeRepository mapTypeRepository;
    @Resource
    MapManagementRepository mapManagementRepository;
    @Autowired
    VillageTownConditionRepository villageTownConditionRepository;
    @Autowired
    VillageTownHosPeoRepository villageTownHosPeoRepository;
    @Autowired
    KangZhenTuRepository kangZhenTuRepository;
    @Autowired
    DictService dictService;
    @Autowired
    DictItemService dictItemService;
    @Autowired
    KpExamIndex3PeekDataDao kpExamIndex3PeekDataDao;



    @Autowired
    DataLumeRepository dataLumeRepository;

    /**
     * 历史地震信息
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @return
     */
    public BigDecimal getSystemScoreNum1(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (historicalSeismicDataRepository.countByCounty(area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (historicalSeismicDataRepository.countByCounty(county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (historicalSeismicDataRepository.countByCounty(county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (historicalSeismicDataRepository.countByCounty(area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (historicalSeismicDataRepository.countByCounty(county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }

        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 历史地震灾害
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum2(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (earthquakeDisasterRepository.countByCounty(area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (earthquakeDisasterRepository.countByCounty(county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (earthquakeDisasterRepository.countByCounty(county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (earthquakeDisasterRepository.countByCounty(area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (earthquakeDisasterRepository.countByCounty(county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 历史预评估
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum3(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (hisPrRepository.countByCounty(area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (hisPrRepository.countByCounty(county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (hisPrRepository.countByCounty(county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (hisPrRepository.countByCounty(area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (hisPrRepository.countByCounty(county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 区县综合概况
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum4(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (countiesConditionRepository.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (countiesConditionRepository.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (countiesConditionRepository.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (countiesConditionRepository.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (countiesConditionRepository.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 人口和建筑物概况
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum5(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (hosPeoRepository.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (hosPeoRepository.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (hosPeoRepository.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (hosPeoRepository.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (hosPeoRepository.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 人口普查数据
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum6(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (peoService.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (peoService.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (peoService.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (peoService.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (peoService.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 建筑物易损性
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum7(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (buildingVulnerabilityService.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (buildingVulnerabilityService.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (buildingVulnerabilityService.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (buildingVulnerabilityService.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (buildingVulnerabilityService.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 房屋造价数据
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum8(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (houseService.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (houseService.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (houseService.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (houseService.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (houseService.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 重大工程基础设施
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum9(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (keyProjectService.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (keyProjectService.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (keyProjectService.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (keyProjectService.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (keyProjectService.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * GDP数据
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum10(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (gdpService.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (gdpService.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (gdpService.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (gdpService.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (gdpService.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 应急准备情况
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum11(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (seismicSetoutService.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (seismicSetoutService.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (seismicSetoutService.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (seismicSetoutService.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (seismicSetoutService.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 行政区划
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum12(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (areaMapService.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (areaMapService.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (areaMapService.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (areaMapService.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (areaMapService.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 高程
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return elevationService
     */
    public BigDecimal getSystemScoreNum13(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
/*        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (elevationService.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (elevationService.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (elevationService.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (elevationService.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (elevationService.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }*/
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省") || area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    List<HeightAndSlopeVO> heightNumlist = dataLumeRepository.getDisHeightNum(currProvinceName, "地形地貌（高程）_");
                    for (HeightAndSlopeVO heightentity : heightNumlist) {
                        if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isEmpty(heightentity.getCity()) && heightentity.getProvince().equals(area[0])) {
                            hasNum = hasNum.add(BigDecimal.ONE);
                            break;
                        }
                        if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isNotEmpty(heightentity.getCity()) && heightentity.getCity().equals(area[1])) {
                            hasNum = hasNum.add(BigDecimal.ONE);
                            break;
                        }
                        if (PlatformObjectUtils.isNotEmpty(heightentity.getArea()) && heightentity.getArea().equals(area[2])) {
                            hasNum = hasNum.add(BigDecimal.ONE);
                            break;
                        }
                    }
                }
                if (area.length == 2) {
                    countyNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByCity(area[1]));
                    List<HeightAndSlopeVO> heightNumlist = dataLumeRepository.getDisHeightNum(currProvinceName, "地形地貌（高程）_");
                    for (HeightAndSlopeVO heightentity : heightNumlist) {
                        if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isEmpty(heightentity.getCity()) && heightentity.getProvince().equals(area[0])) {
                            hasNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByCity(heightentity.getCity()));
                            break;
                        }
                        if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isNotEmpty(heightentity.getCity()) && heightentity.getCity().equals(area[1])) {
                            hasNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByCity(heightentity.getCity()));
                            break;
                        }
                        if (PlatformObjectUtils.isNotEmpty(heightentity.getArea())&&PlatformObjectUtils.isNotEmpty(heightentity.getCity())&&heightentity.getCity().equals(area[1])){
                            hasNum = hasNum.add(BigDecimal.ONE);
                            continue;
                        }


                    }
                }if (area.length == 1) {
                    countyNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByProvince(area[0]));
                    List<HeightAndSlopeVO> heightNumlist = dataLumeRepository.getDisHeightNum(currProvinceName, "地形地貌（高程）_");
                    for (HeightAndSlopeVO heightentity : heightNumlist) {
                        if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isEmpty(heightentity.getCity())) {
                            hasNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByProvince(heightentity.getProvince()));
                            break;
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                    if (area.length == 2) {
                        countyNum = countyNum.add(BigDecimal.ONE);
                        List<HeightAndSlopeVO> heightNumlist = dataLumeRepository.getDisHeightNum(currProvinceName, "地形地貌（高程）_");
                        for (HeightAndSlopeVO heightentity : heightNumlist) {
                            if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isEmpty(heightentity.getCity())) {
                                // heightNum=dataLumeRepository.getcountyNumByProvince(heightentity.getProvince());
                                hasNum = hasNum.add(BigDecimal.ONE);
                                break;
                            }
                            if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isNotEmpty(heightentity.getCity()) && heightentity.getCity().equals(area[0])) {
                                //heightNum+=dataLumeRepository.getcountyNumByCity(heightentity.getCity());
                                hasNum = hasNum.add(BigDecimal.ONE);
                                break;
                            }
                            if (PlatformObjectUtils.isNotEmpty(heightentity.getArea()) && heightentity.getArea().equals(area[1])) {
                                //heightNum+=dataLumeRepository.getcountyNumByCity(heightentity.getCity());
                                hasNum = hasNum.add(BigDecimal.ONE);
                                break;
                            }
                        }
                    }
                    if (area.length == 1) {
                        countyNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByProvince(area[0]));
                        List<HeightAndSlopeVO> heightNumlist = dataLumeRepository.getDisHeightNum(currProvinceName, "地形地貌（高程）_");
                        for (HeightAndSlopeVO heightentity : heightNumlist) {
                            if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isEmpty(heightentity.getCity())) {
                                hasNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByProvince(heightentity.getProvince()));
                                break;
                            }
                            if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isNotEmpty(heightentity.getCity())) {
                                hasNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByCity(heightentity.getCity()));
                                break;
                            }
                            if (PlatformObjectUtils.isNotEmpty(heightentity.getArea())) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
        // return countyNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : countyNum.divide(hasNum, 1, RoundingMode.HALF_UP).multiply(score);
    }


    /**
     * 坡度
     * statisticsService
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum14(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省") || area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    List<HeightAndSlopeVO> heightNumlist = dataLumeRepository.getDisHeightNum(currProvinceName, "地形地貌（坡度）_");
                    for (HeightAndSlopeVO heightentity : heightNumlist) {
                        if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isEmpty(heightentity.getCity()) && heightentity.getProvince().equals(area[0])) {
                            hasNum = hasNum.add(BigDecimal.ONE);
                            break;
                        }
                        if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isNotEmpty(heightentity.getCity()) && heightentity.getCity().equals(area[1])) {
                            hasNum = hasNum.add(BigDecimal.ONE);
                            break;
                        }
                        if (PlatformObjectUtils.isNotEmpty(heightentity.getArea()) && heightentity.getArea().equals(area[2])) {
                            hasNum = hasNum.add(BigDecimal.ONE);
                            break;
                        }
                    }
                }
                if (area.length == 2) {
                    countyNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByCity(area[1]));
                    List<HeightAndSlopeVO> heightNumlist = dataLumeRepository.getDisHeightNum(currProvinceName, "地形地貌（坡度）_");
                    for (HeightAndSlopeVO heightentity : heightNumlist) {
                        if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isEmpty(heightentity.getCity()) && heightentity.getProvince().equals(area[0])) {
                            hasNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByCity(heightentity.getCity()));
                            break;
                        }
                        if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isNotEmpty(heightentity.getCity()) && heightentity.getCity().equals(area[1])) {
                            hasNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByCity(heightentity.getCity()));
                            break;
                        }
                        if (PlatformObjectUtils.isNotEmpty(heightentity.getArea())&&PlatformObjectUtils.isNotEmpty(heightentity.getCity())&&heightentity.getCity().equals(area[1])){
                            hasNum = hasNum.add(BigDecimal.ONE);
                            continue;
                        }

                    }
                }
                if (area.length == 1) {
                    countyNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByProvince(area[0]));
                    List<HeightAndSlopeVO> heightNumlist = dataLumeRepository.getDisHeightNum(currProvinceName, "地形地貌（坡度）_");
                    for (HeightAndSlopeVO heightentity : heightNumlist) {
                        if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isEmpty(heightentity.getCity())) {
                            hasNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByProvince(heightentity.getProvince()));
                            break;
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    List<HeightAndSlopeVO> heightNumlist = dataLumeRepository.getDisHeightNum(currProvinceName, "地形地貌（坡度）_");
                    for (HeightAndSlopeVO heightentity : heightNumlist) {
                        if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isEmpty(heightentity.getCity())) {
                            // heightNum=dataLumeRepository.getcountyNumByProvince(heightentity.getProvince());
                            hasNum = hasNum.add(BigDecimal.ONE);
                            break;
                        }
                        if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isNotEmpty(heightentity.getCity()) && heightentity.getCity().equals(area[0])) {
                            //heightNum+=dataLumeRepository.getcountyNumByCity(heightentity.getCity());
                            hasNum = hasNum.add(BigDecimal.ONE);
                            break;
                        }
                        if (PlatformObjectUtils.isNotEmpty(heightentity.getArea()) && heightentity.getArea().equals(area[1])) {
                            //heightNum+=dataLumeRepository.getcountyNumByCity(heightentity.getCity());
                            hasNum = hasNum.add(BigDecimal.ONE);
                            break;
                        }
                    }
                }
                if (area.length == 1) {
                    countyNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByProvince(area[0]));
                    List<HeightAndSlopeVO> heightNumlist = dataLumeRepository.getDisHeightNum(currProvinceName, "地形地貌（坡度）_");
                    for (HeightAndSlopeVO heightentity : heightNumlist) {
                        if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isEmpty(heightentity.getCity())) {
                            hasNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByProvince(heightentity.getProvince()));
                            break;
                        }
                        if (PlatformObjectUtils.isEmpty(heightentity.getArea()) && PlatformObjectUtils.isNotEmpty(heightentity.getCity())) {
                            hasNum = BigDecimal.valueOf(dataLumeRepository.getcountyNumByCity(heightentity.getCity()));
                            break;
                        }
                        if (PlatformObjectUtils.isNotEmpty(heightentity.getArea())) {
                            hasNum = hasNum.add(BigDecimal.ONE);
                        }
                    }
                }
            }
        }
        // 查询当前分值
            // return countyNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : countyNum.divide(hasNum, 1, RoundingMode.HALF_UP).multiply(score);
         return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 人口和建筑物经济公里格网
     * pbeRepository
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum15(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (pbeRepository.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (pbeRepository.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (pbeRepository.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (pbeRepository.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (pbeRepository.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 道路
     * roadRepository
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum16(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (roadRepository.countByProvince(area[0])>0){
                        hasNum = hasNum.add(BigDecimal.ONE);
                        break;
                    }if (roadRepository.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (roadRepository.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (roadRepository.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (roadRepository.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (roadRepository.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 机场
     * airportRepository
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum17(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            countyNum = countyNum.add(BigDecimal.ONE);
            if (airportRepository.countByProvince(area[0])>0){
                hasNum = BigDecimal.ONE;
            }
/*            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (airportRepository.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (airportRepository.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (airportRepository.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (airportRepository.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (airportRepository.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }*/
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 水库
     * reservoirRepository
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum18(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (reservoirRepository.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (reservoirRepository.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (reservoirRepository.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (reservoirRepository.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (reservoirRepository.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 学校
     * schoolRepository
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum19(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (schoolRepository.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (schoolRepository.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (schoolRepository.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (schoolRepository.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (schoolRepository.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 医院
     * hospitalRepository
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum20(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (hospitalRepository.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (hospitalRepository.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (hospitalRepository.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (hospitalRepository.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (hospitalRepository.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 地址灾害
     * geologicalRepository
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum21(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (geologicalRepository.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (geologicalRepository.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (geologicalRepository.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (geologicalRepository.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (geologicalRepository.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 活动断层
     * faultageRepository
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum22(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (faultageRepository.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (faultageRepository.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (faultageRepository.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (faultageRepository.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (faultageRepository.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 危化企业
     * riskEnterpriseDataRepository
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum23(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (riskEnterpriseDataRepository.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (riskEnterpriseDataRepository.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (riskEnterpriseDataRepository.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (riskEnterpriseDataRepository.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (riskEnterpriseDataRepository.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 加油站
     * gasstationDataRepository
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum24(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (gasstationDataRepository.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (gasstationDataRepository.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (gasstationDataRepository.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (gasstationDataRepository.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (gasstationDataRepository.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 应急避难场所
     * emergencyShelterRepository
     *
     * @param ypgId
     * @param score
     * @param provinceMap
     * @param currProvinceId
     * @return
     */
    public BigDecimal getSystemScoreNum25(String ypgId, BigDecimal score, Map<String, String> provinceMap, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (emergencyShelterRepository.countByCounty(area[0], area[1], area[2]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (emergencyShelterRepository.countByCounty(area[0], area[1], county.getString("name")) > 0) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (emergencyShelterRepository.countByCounty(area[0], city.getString("name"), county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (emergencyShelterRepository.countByCounty(area[0], area[0], area[1]) > 0) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (emergencyShelterRepository.countByCounty(area[0], area[0], county.getString("name")) > 0) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }
        // 查询当前分值
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 平台更新数据
     *
     * @return
     */
    public BigDecimal getSystemScoreNum26(String ypgId, BigDecimal score, String kesdi3Id, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        int i = 0;
        String provinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        List<KpExamIndex3PeekData> peekDataList = kpExamIndex3PeekDataDao.selectByKesdi3id(kesdi3Id);
        for (KpExamIndex3PeekData peekData : peekDataList) {
            if (peekData.equals(KpPtgxCode.kplsdz)) {
                Integer count = historicalSeismicDataRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kplsdzzh)) {
                Integer count = earthquakeDisasterRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kplsypg)) {
                Integer count = hisPrRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpqxzhgk)) {
                Integer count = countiesConditionRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpxzzhgk)) {
                Integer count = villageTownConditionRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpqxrkhjzwgk)) {
                Integer count = hosPeoRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpxzrkhjzwgk)) {
                Integer count = villageTownHosPeoRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kprkpc)) {
                Integer count = peoService.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpjzwysx)) {
                Integer count = buildingVulnerabilityService.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpfwzj)) {
                Integer count = houseService.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpzdgcjcss)) {
                Integer count = keyProjectService.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpgdp)) {
                Integer count = gdpService.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpyjzbqk)) {
                Integer count = seismicSetoutService.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpxzqh)) {
                Integer count = areaMapService.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpgc)) {
                Integer count = elevationService.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kppd)) {
                Integer count = statisticsService.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kprkjzwjjglgw)) {
                Integer count = pbeRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpdl)) {
                Integer count = roadRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpjc)) {
                Integer count = airportRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpsk)) {
                Integer count = reservoirRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpxx)) {
                Integer count = schoolRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpyy)) {
                Integer count = hospitalRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpdzzh)) {
                Integer count = geologicalRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kphddc)) {
                Integer count = faultageRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpwhqy)) {
                Integer count = riskEnterpriseDataRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpjyjqz)) {
                Integer count = gasstationDataRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpyjbncs)) {
                Integer count = emergencyShelterRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
            if (peekData.equals(KpPtgxCode.kpjyygdfwkznlcbpg)) {
                Integer count = kangZhenTuRepository.countByProvinceAndYear(provinceName, ypgTask.getTaskYear());
                if (count > 0) {
                    i++;
                }
            }
        }
        if (i == 0) {
            return BigDecimal.ZERO;
        }
        return (BigDecimal.valueOf(i).divide(BigDecimal.valueOf(peekDataList.size()), 1, RoundingMode.HALF_UP)).multiply(score);
    }

    /**
     * 烈度衰减关系
     *
     * @return
     */
    public BigDecimal getSystemScoreNum27(String currProvinceId, BigDecimal score) {
        if (intensityAttenuationRepository.countByProvince(sysAreaCacheService.getAreaNameByAreaId(currProvinceId)) > 0) {
            return score;
        }
        return BigDecimal.ZERO;
    }

    /**
     * 人员伤亡
     *
     * @return
     */
    public BigDecimal getSystemScoreNum28(String currProvinceId, BigDecimal score) {
        if (casualtyRepository.countByProvince(sysAreaCacheService.getAreaNameByAreaId(currProvinceId)) > 0) {
            return score;
        }
        return BigDecimal.ZERO;
    }

    /**
     * 经济损失
     *
     * @return
     */
    public BigDecimal getSystemScoreNum29(String currProvinceId, BigDecimal score) {
        if (economicLossesRepository.countByProvince(sysAreaCacheService.getAreaNameByAreaId(currProvinceId)) > 0) {
            return score;
        }
        return BigDecimal.ZERO;
    }

    /**
     * 需紧急安职人数
     *
     * @return
     */
    public BigDecimal getSystemScoreNum30(String currProvinceId, BigDecimal score) {
        if (resettlementPersonnelRepository.countByProvince(sysAreaCacheService.getAreaNameByAreaId(currProvinceId)) > 0) {
            return score;
        }
        return BigDecimal.ZERO;
    }

    /**
     * 救援力量
     *
     * @return
     */
    public BigDecimal getSystemScoreNum31(String currProvinceId, BigDecimal score) {
        if (rescueForceRepository.countByProvince(sysAreaCacheService.getAreaNameByAreaId(currProvinceId)) > 0) {
            return score;
        }
        return BigDecimal.ZERO;
    }

    /**
     * 物资需求
     *
     * @return
     */
    public BigDecimal getSystemScoreNum32(String currProvinceId, BigDecimal score) {
        if (materialRepository.countByProvince(sysAreaCacheService.getAreaNameByAreaId(currProvinceId)) > 0) {
            return score;
        }
        return BigDecimal.ZERO;
    }

    /**
     * 区县致死性差异性指标权重
     *
     * @return
     */
    public BigDecimal getSystemScoreNum33(String currProvinceId, BigDecimal score) {
        if (lethalityDifferenceRepository.countByProvince(sysAreaCacheService.getAreaNameByAreaId(currProvinceId)) > 0) {
            return score;
        }
        return BigDecimal.ZERO;
    }

    /**
     * 本地化模型参数优化
     *
     * @return
     */
    public BigDecimal getSystemScoreNum34(String ypgId, BigDecimal score, String currProvinceId) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        if (intensityAttenuationRepository.countByYearPrefixLike(ypgTask.getTaskYear(), currProvinceId) > 0) {
            return score;
        }
        if (casualtyRepository.countByYearPrefixLike(ypgTask.getTaskYear(), currProvinceId) > 0) {
            return score;
        }
        if (economicLossesRepository.countByYearPrefixLike(ypgTask.getTaskYear(), currProvinceId) > 0) {
            return score;
        }
        if (resettlementPersonnelRepository.countByYearPrefixLike(ypgTask.getTaskYear(), currProvinceId) > 0) {
            return score;
        }
        if (rescueForceRepository.countByYearPrefixLike(ypgTask.getTaskYear(), currProvinceId) > 0) {
            return score;
        }
        if (materialRepository.countByYearPrefixLike(ypgTask.getTaskYear(), currProvinceId) > 0) {
            return score;
        }
        if (lethalityDifferenceRepository.countByYearPrefixLike(ypgTask.getTaskYear(), currProvinceId) > 0) {
            return score;
        }
        return BigDecimal.ZERO;
    }

    /**
     * 调研点选取
     *
     * @return
     */
    public BigDecimal getSystemScoreNum35(String ypgId, String xcdcId, String currProvinceId, BigDecimal score, Map<String, String> provinceMap) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        FieldSurveyTaskEntity xcdcTask = fieldSurveyTaskService.getById(xcdcId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内乡镇总个数
        BigDecimal xzNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    List<String> steelList = areaMapService.getByCounty(area[0], area[1], area[2]);
                    if (steelList != null) {
                        for (String s : steelList) {
                            xzNum = xzNum.add(BigDecimal.ONE);
                            if (samplingReqository.countByAreaNameAndTask(xcdcTask.getTaskNum(), area[0], area[1], area[2], s) >= 2) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            for (Object countyObj : countyArr) {
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                List<String> steelList = areaMapService.getByCounty(area[0], area[1], county.getString("name"));
                                if (steelList != null) {
                                    for (String s : steelList) {
                                        xzNum = xzNum.add(BigDecimal.ONE);
                                        if (samplingReqository.countByAreaNameAndTask(xcdcTask.getTaskNum(), area[0], area[1], county.getString("name"), s) >= 2) {
                                            hasNum = hasNum.add(BigDecimal.ONE);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        for (JSONObject county : countyList) {
                            List<String> steelList = areaMapService.getByCounty(area[0], area[1], county.getString("name"));
                            if (steelList != null) {
                                for (String s : steelList) {
                                    xzNum = xzNum.add(BigDecimal.ONE);
                                    if (samplingReqository.countByAreaNameAndTask(xcdcTask.getTaskNum(), area[0], city.getString("name"), county.getString("name"), s) >= 2) {
                                        hasNum = hasNum.add(BigDecimal.ONE);
                                    }
                                }
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    List<String> steelList = areaMapService.getByCounty(area[0], area[0], area[1]);
                    if (steelList != null) {
                        for (String s : steelList) {
                            xzNum = xzNum.add(BigDecimal.ONE);
                            if (samplingReqository.countByAreaNameAndTask(xcdcTask.getTaskNum(), area[0], area[0], area[1], s) >= 2) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        for (JSONObject county : countyList) {
                            List<String> steelList = areaMapService.getByCounty(area[0], area[1], county.getString("name"));
                            if (steelList != null) {
                                for (String s : steelList) {
                                    xzNum = xzNum.add(BigDecimal.ONE);
                                    if (samplingReqository.countByAreaNameAndTask(xcdcTask.getTaskNum(), area[0], city.getString("name"), county.getString("name"), s) >= 2) {
                                        hasNum = hasNum.add(BigDecimal.ONE);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(xzNum, 4, RoundingMode.HALF_UP).multiply(score).setScale(1,RoundingMode.HALF_UP);
    }

    /**
     * 房屋抽取调研点选取
     *
     * @return
     */
    public BigDecimal getSystemScoreNum36(String xcdcId, String currProvinceId, BigDecimal score) {
        FieldSurveyTaskEntity task = fieldSurveyTaskService.getById(xcdcId);
        List<SamplingEntity> samplingList = samplingReqository.getByTaskCodeAndProvinceId(task.getTaskNum(), currProvinceId);
        if (samplingList == null) {
            return BigDecimal.ZERO;
        }
        for (SamplingEntity samplingEntity : samplingList) {
            String highStructure = samplingEntity.getHighStructure();
            if (StringUtils.isNotBlank(highStructure) && !highStructure.equals(BuildingStructureConstants.HIGH_STRUCTURE)) {
                Integer total = buildingReqository.countBySurveyNameAndTaksCodeAndProvinceIdAndStructure(samplingEntity.getId(), task.getTaskNum(), samplingEntity.getProvinceId(), BuildingStructureConstants.HIGH_STRUCTURE);
                if (total < 5) {
                    return BigDecimal.ZERO;
                }
            }
            String steelStructure = samplingEntity.getSteelStructure();
            if (StringUtils.isNotBlank(steelStructure) && !steelStructure.equals(BuildingStructureConstants.STEEL_STRUCTURE)) {
                Integer total = buildingReqository.countBySurveyNameAndTaksCodeAndProvinceIdAndStructure(samplingEntity.getId(), task.getTaskNum(), samplingEntity.getProvinceId(), BuildingStructureConstants.STEEL_STRUCTURE);
                if (total < 5) {
                    return BigDecimal.ZERO;
                }
            }
            String concreteStructure = samplingEntity.getConcreteStructure();
            if (StringUtils.isNotBlank(concreteStructure) && !concreteStructure.equals(BuildingStructureConstants.HNT_STRUCTURE)) {
                Integer total = buildingReqository.countBySurveyNameAndTaksCodeAndProvinceIdAndStructure(samplingEntity.getId(), task.getTaskNum(), samplingEntity.getProvinceId(), BuildingStructureConstants.HNT_STRUCTURE);
                if (total < 5) {
                    return BigDecimal.ZERO;
                }
            }
            String masonryStructure = samplingEntity.getMasonryStructure();
            if (StringUtils.isNotBlank(masonryStructure) && !masonryStructure.equals(BuildingStructureConstants.ZH_STRUCTURE)) {
                Integer total = buildingReqository.countBySurveyNameAndTaksCodeAndProvinceIdAndStructure(samplingEntity.getId(), task.getTaskNum(), samplingEntity.getProvinceId(), BuildingStructureConstants.ZH_STRUCTURE);
                if (total < 5) {
                    return BigDecimal.ZERO;
                }
            }
            String brickWoodStructure = samplingEntity.getBrickWoodStructure();
            if (StringUtils.isNotBlank(brickWoodStructure) && !brickWoodStructure.equals(BuildingStructureConstants.ZM_STRUCTURE)) {
                Integer total = buildingReqository.countBySurveyNameAndTaksCodeAndProvinceIdAndStructure(samplingEntity.getId(), task.getTaskNum(), samplingEntity.getProvinceId(), BuildingStructureConstants.ZM_STRUCTURE);
                if (total < 5) {
                    return BigDecimal.ZERO;
                }
            }
            String soilStructure = samplingEntity.getSoilStructure();
            if (StringUtils.isNotBlank(soilStructure) && !soilStructure.equals(BuildingStructureConstants.SOIL_STRUCTURE)) {
                Integer total = buildingReqository.countBySurveyNameAndTaksCodeAndProvinceIdAndStructure(samplingEntity.getId(), task.getTaskNum(), samplingEntity.getProvinceId(), BuildingStructureConstants.SOIL_STRUCTURE);
                if (total < 5) {
                    return BigDecimal.ZERO;
                }
            }
            String woodStructure = samplingEntity.getWoodStructure();
            if (StringUtils.isNotBlank(woodStructure) && !woodStructure.equals(BuildingStructureConstants.WOOD_STRUCTURE)) {
                Integer total = buildingReqository.countBySurveyNameAndTaksCodeAndProvinceIdAndStructure(samplingEntity.getId(), task.getTaskNum(), samplingEntity.getProvinceId(), BuildingStructureConstants.WOOD_STRUCTURE);
                if (total < 5) {
                    return BigDecimal.ZERO;
                }
            }
            String stoneStructure = samplingEntity.getStoneStructure();
            if (StringUtils.isNotBlank(stoneStructure) && !stoneStructure.equals(BuildingStructureConstants.STONE_STRUCTURE)) {
                Integer total = buildingReqository.countBySurveyNameAndTaksCodeAndProvinceIdAndStructure(samplingEntity.getId(), task.getTaskNum(), samplingEntity.getProvinceId(), BuildingStructureConstants.STONE_STRUCTURE);
                if (total < 5) {
                    return BigDecimal.ZERO;
                }
            }
            String otherStructure = samplingEntity.getOtherStructure();
            if (StringUtils.isNotBlank(otherStructure) && !otherStructure.equals(BuildingStructureConstants.OTHER_STRUCTURE)) {
                Integer total = buildingReqository.countBySurveyNameAndTaksCodeAndProvinceIdAndStructure(samplingEntity.getId(), task.getTaskNum(), samplingEntity.getProvinceId(), BuildingStructureConstants.OTHER_STRUCTURE);
                if (total < 5) {
                    return BigDecimal.ZERO;
                }
            }
        }
        return score;
    }

    /**
     * 抽样点调查点概况信息填写
     *
     * @return
     */
    public BigDecimal getSystemScoreNum37(String currProvinceId, String xcdcId, BigDecimal score) {
        FieldSurveyTaskEntity task = fieldSurveyTaskService.getById(xcdcId);
        List<FieldSurveyTaskEntity> childrenList=fieldSurveyTaskService.getChildrenByParentId(task.getId());
        Integer total = samplingReqository.countByTaskCodeAndProvinceId(task.getTaskNum(), currProvinceId);
        Integer commitTotal = samplingReqository.countCommitByTaskCodeAndProvinceId(task.getTaskNum(), currProvinceId);
        if (PlatformObjectUtils.isNotEmpty(childrenList)){
            for (FieldSurveyTaskEntity entity : childrenList) {
                total+=samplingReqository.countByTaskCodeAndProvinceId(entity.getTaskNum(), currProvinceId);
                commitTotal+= samplingReqository.countCommitByTaskCodeAndProvinceId(entity.getTaskNum(), currProvinceId);
            }
        }
        if (total == 0) {
            return BigDecimal.ZERO;
        }
        if (commitTotal == 0) {
            return BigDecimal.ZERO;
        }
        return BigDecimal.valueOf(commitTotal).divide(BigDecimal.valueOf(total), 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 对策建议维护
     *
     * @return
     */
    public BigDecimal getSystemScoreNum38(String ypgId, String
            currProvinceId, Map<String, String> provinceMap, BigDecimal score) {
        PreAssessTaskEntity ypgTask = preAssessTaskService.getById(ypgId);
        String currProvinceName = sysAreaCacheService.getAreaNameByAreaId(currProvinceId);
        // 任务范围内区县总个数
        BigDecimal countyNum = BigDecimal.ZERO;
        BigDecimal hasNum = BigDecimal.ZERO;
        String[] allAreaArr = ypgTask.getTaskDistrict().split("、");
        for (String areaStr : allAreaArr) {
            if (!areaStr.contains(currProvinceName)) {
                continue;
            }
            String[] area = areaStr.split("-");
            if (area[0].endsWith("省")||area[0].endsWith("自治区")) {
                // 区县
                if (area.length == 3) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (dcjyIsManage(area[0], area[1], area[2])) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 2) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    JSONArray tree = JSONObject.parseArray(treeStr);
                    for (Object city : tree) {
                        if (JSONObject.parseObject(JSONObject.toJSONString(city)).getString("name").equals(area[1])) {
                            String countyStr = sysAreaService.jsonSAreaTree(JSONObject.parseObject(JSONObject.toJSONString(city)).getString("id"));
                            JSONArray countyArr = JSONObject.parseArray(countyStr);
                            countyNum = countyNum.add(BigDecimal.valueOf(countyArr.size()));
                            for (Object countyObj : countyArr) {
                              //  JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                JSONObject county = JSONObject.parseObject(JSONObject.toJSONString(countyObj));
                                if (dcjyIsManage(area[0], area[1], county.getString("name"))) {
                                    hasNum = hasNum.add(BigDecimal.ONE);
                                }
                            }
                        }
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (dcjyIsManage(area[0], city.getString("name"), county.getString("name"))) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            } else if (area[0].endsWith("市")) {
                if (area.length == 2) {
                    countyNum = countyNum.add(BigDecimal.ONE);
                    if (dcjyIsManage(area[0], area[0], area[1])) {
                        hasNum = hasNum.add(BigDecimal.ONE);
                    }
                }
                if (area.length == 1) {
                    String treeStr = sysAreaService.jsonSAreaTree(provinceMap.get(area[0]));
                    List<JSONObject> cityList = JSONObject.parseArray(treeStr, JSONObject.class);
                    for (JSONObject city : cityList) {
                        List<JSONObject> countyList = JSONObject.parseArray(sysAreaService.jsonSAreaTree(city.getString("id")), JSONObject.class);
                        countyNum = countyNum.add(BigDecimal.valueOf(countyList.size()));
                        for (JSONObject county : countyList) {
                            if (dcjyIsManage(area[0], city.getString("name"), county.getString("name"))) {
                                hasNum = hasNum.add(BigDecimal.ONE);
                            }
                        }
                    }
                }
            }
        }

        return hasNum.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : hasNum.divide(countyNum, 1, RoundingMode.HALF_UP).multiply(score);
    }

    /**
     * 成果管理 报告(含生成)
     *
     * @return
     */
    public BigDecimal getSystemScoreNum39(String ypgId, String xcdcId, BigDecimal score) {
        ReportManagement ypgReport = reportManagementRepository.getReportByTaskId(ypgId);
        FieldReportManagement xcReport = samplingSurveyReportRepository.getReportByTaskId(xcdcId);
        if (ypgReport == null) {
            return BigDecimal.ZERO;
        }
        if (xcReport == null) {
            return BigDecimal.ZERO;
        }
        if (StringUtils.isBlank(ypgReport.getDefaultSimpleReportName())) {
            return BigDecimal.ZERO;
        }
        if (StringUtils.isBlank(ypgReport.getDefaultMinuteReportName())) {
            return BigDecimal.ZERO;
        }
        if (StringUtils.isBlank(ypgReport.getUserUploadSimpleReportName())) {
            return BigDecimal.ZERO;
        }
        if (StringUtils.isBlank(ypgReport.getUserUploadMinuteReportName())) {
            return BigDecimal.ZERO;
        }
        if (StringUtils.isBlank(xcReport.getDefaultReportName())) {
            return BigDecimal.ZERO;
        }
        if (StringUtils.isBlank(xcReport.getUserUploadReportName())) {
            return BigDecimal.ZERO;
        }
        return score;
    }

    /**
     * 成果管理 报告
     *
     * @return
     */
    public BigDecimal getSystemScoreNum40(String ypgId, String xcdcId, BigDecimal score) {
        ReportManagement ypgReport = reportManagementRepository.getReportByTaskId(ypgId);
        FieldReportManagement xcReport = samplingSurveyReportRepository.getReportByTaskId(xcdcId);
        if (ypgReport == null) {
            return BigDecimal.ZERO;
        }
        if (xcReport == null) {
            return BigDecimal.ZERO;
        }
        if (StringUtils.isBlank(ypgReport.getUserUploadSimpleReportName())) {
            return BigDecimal.ZERO;
        }
        if (StringUtils.isBlank(ypgReport.getUserUploadMinuteReportName())) {
            return BigDecimal.ZERO;
        }
        if (StringUtils.isBlank(xcReport.getUserUploadReportName())) {
            return BigDecimal.ZERO;
        }
        return score;
    }

    /**
     * 成果管理 图件
     *
     * @return
     */
    public BigDecimal getSystemScoreNum41(String ypgId, String xcdcId, BigDecimal score) {
        List<MapType> ypgTjBase = mapTypeRepository.getByReportType("0");
        List<MapType> xcTjBase = mapTypeRepository.getByReportType("1");
        List<String> ypgTj = mapManagementRepository.getMapClassifyByTaskId(ypgId);
        if (ypgTj.size() != ypgTjBase.size()) {
            return BigDecimal.ZERO;
        }
        List<String> xcTj = mapManagementRepository.getMapClassifyByTaskId(xcdcId);
        if (xcTj.size() != xcTjBase.size()) {
            return BigDecimal.ZERO;
        }
        return score;
    }

    private boolean dcjyIsManage(String provinceName, String cityName, String countyName) {
        Integer total1 = disasterScenarioManageRepository.countByCounty(provinceName, cityName, countyName);
        Integer total2 = annualRiskManageRepository.countByCounty(provinceName, cityName, countyName);
        Integer total3 = emergencyDisasterManageRepository.countByCounty(provinceName, cityName, countyName);
        Integer total4 = emergencyDisposalManageRepository.countByCounty(provinceName, cityName, countyName);
        if (total1 > 0 && total2 > 0 && total3 > 0 && total4 > 0) {
            return true;
        }
        return false;
    }
}
